package com.min.nio.rpc.client;

import com.min.nio.api.HelloWorld;
import com.min.nio.api.TestApi;
import com.min.nio.module.Student;

import java.lang.reflect.Proxy;
import java.util.Map;

/**
 * create by sirmin on 2018/3/21
 */
public class ApiProxy {
    Map<Class<?>, Object> porxies;

    public static Object getApi(final Class<?> clazz) {
        return Proxy.newProxyInstance(ApiProxy.class.getClassLoader(), new Class<?>[]{clazz}, (proxy, method, args) -> {
            Object o = null;
            if(args != null && args.length > 0) {
                o = args[0];
            }
            return new Client().transform(clazz, method, o);
        });
    }

    public static void main(String[] args) {
        final TestApi api = (TestApi) ApiProxy.getApi(TestApi.class);
        System.out.println(api.getDate());

    }
}
